import 'package:fijkplayer_plus/fijkplayer_plus.dart';
import 'package:flutter/material.dart';
import 'package:player/player.dart';

class VideoView extends StatefulWidget {
  final Player mPlayer;

  const VideoView({required this.mPlayer});

  @override
  _VideoViewState createState() {
    return _VideoViewState();
  }
}

class _VideoViewState extends State<VideoView> {
  @override
  void initState() {
    super.initState();
  }

  @override
  void dispose() {
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: _changePlayState,
      child: Stack(
        children: [
          Container(
            decoration: BoxDecoration(
              color: Colors.purpleAccent,
              borderRadius: BorderRadius.all(Radius.circular(10))
            ),
            
            width: double.infinity,
            height: 200,
            child:AbsorbPointer(
              absorbing: true,
              child: FijkView(player: widget.mPlayer,fit: FijkFit.fitWidth,),
            ) ,
          ),
          Text("videoView"),
          Positioned(
            left: 150,
            top: 150,
            child: TextButton(
              onPressed: _changePlayState,
              child: Text(
                widget.mPlayer.state.name,
                style: TextStyle(color: Colors.redAccent, fontSize: 13),
              ),
            ),
          ),
        ],
      ),
    );
  }

  _changePlayState() {
    print("onTap");
    widget.mPlayer.pause();
    setState(() {});
  }
}
